﻿using System;
using System.Collections.Generic;
using System.Text;
using Mang24k99.Model.PUBC;
using NHibernate;
using NHibernate.Expression;
using Castle.ActiveRecord.Queries;
namespace Mang24k99.Business.PUBC
{
    public partial class BKtPubcVotelimit
    {
        public static void Create(MKtPubcVotelimit model)
        {
            model.IsValidate = 1;
            model.InputTime = DateTime.Now;
            model.ModifyTime = DateTime.Now;
            model.DeleteTime = DateTime.Now;
            model.Create();
        }
        public static void Update(MKtPubcVotelimit model)
        {
            model.ModifyTime = DateTime.Now;
            model.Update();
        }
        public static void Delete(MKtPubcVotelimit model)
        {
            //删除默认字段在ondelete中执行
            model.Delete();
        }

        public static IList<MKtPubcVotelimit> FindAll()
        {
            ICriterion[] criteria = new ICriterion[]
            {
                Expression.Eq("IsValidate",1),
            };
            return MKtPubcVotelimit.SelectAll(criteria);
        }

        public static MKtPubcVotelimit Find(object ID)
        {
            return MKtPubcVotelimit.SelectByPrimaryKey(ID);
        }
        public static MKtPubcVotelimit FindOne()
        {
            ICriterion[] criteria = new ICriterion[]
            {
            };
            return MKtPubcVotelimit.SelectOne(criteria);
        }
        public static MKtPubcVotelimit FindFirst()
        {
            ICriterion[] criteria = new ICriterion[]
            {
            };
            return MKtPubcVotelimit.SelectFirst(criteria);
        }

        public static IList<MKtPubcVotelimit> FindALLByProperty(string property, object value)
        {
            return MKtPubcVotelimit.SelectALLByProperty(property, value);
        }

        public static IList<MKtPubcVotelimit> FindALLSliced(int firstResult, int maxResult)
        {
            ICriterion[] criteria = new ICriterion[]
            {
                Expression.Eq("IsValidate",1),
            };
            return MKtPubcVotelimit.SelectALLSliced(firstResult, maxResult, criteria);
        }
        public static IList<MKtPubcVotelimit> FindALLQuery(int firstResult, int maxResult)
        {
            string strHql = @"Select MKtPubcVotelimit"
                          + " from"
                          + " MKtPubcVotelimit MKtPubcVotelimit, MKtPubcProduct MKtPubcProduct, MKtPubcItems MKtPubcItems, MKtPubcCyc MKtPubcCyc"
                          + " where"
                          + " MKtPubcVotelimit.IsValidate = 1"
                          + " and MKtPubcVotelimit.MKtPubcProduct.BoardNO = MKtPubcProduct.BoardNO"
                          + " and MKtPubcVotelimit.MKtPubcItems.ItemNO = MKtPubcItems.ItemNO"
                          + " and MKtPubcVotelimit.MKtPubcCyc.CycNO = MKtPubcCyc.CycNO"
                          ;
            SimpleQuery query = new SimpleQuery(typeof(MKtPubcVotelimit), strHql);
            query.SetQueryRange(firstResult, maxResult);
            return MKtPubcVotelimit.SelectAllQuery(query);
        }
        public static int Count()
        {
            ICriterion[] criteria = new ICriterion[]
            {
                Expression.Eq("IsValidate",1),
            };
            return MKtPubcVotelimit.Counts(criteria);
        }
        public static bool Exists(object id)
        {
            return MKtPubcVotelimit.Exist(id);
        }

    }
}
